package com.kagura.querydrug.controller;

import com.kagura.querydrug.pojo.DrugYpkc;
import com.kagura.querydrug.service.DrugYpkcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @PACKAGE_NAME: com.kagura.querydrug.controller
 * @CLASS_NAME: DrugYpkcController
 * @USER: kagura
 * @Description TODO
 * @Date 2021/6/3 8:39 下午
 * @MONTH_NAME_FULL: 六月
 * @DAY: 03
 * @DAY_NAME_FULL: 星期四
 * @PROJECT_NAME: queryDrug
 **/
@RestController
@RequestMapping(value ="/api")
public class DrugYpkcController {

    // 将service实例注入到spring容器
    @Autowired
    private DrugYpkcService drugYpkcService;

    // 根据药品名称获取药品信息
    @RequestMapping(value = "/getDrugByName", method = RequestMethod.GET)
    public List<DrugYpkc> getDrugYpkc(@RequestParam(value = "name", required = true) String name) {
        return drugYpkcService.findByYPMC(name);
    }

    // 根据发药科室获取药品信息
    @RequestMapping(value = "/getDrugByDept", method = RequestMethod.GET)
    public List<DrugYpkc> getDrugDept(@RequestParam(value = "name", required = true) String name) {
        return drugYpkcService.findByStorageName(name);
    }

}
